<template>
  <section id="uploadBusiness">

   <div class="flex_head">
     <div class="solid"></div>
     <div class="item_two">
       <h3>二维码商户列表</h3>
     </div>
     <el-button type="primary" size="small" @click="goBack">返回</el-button>
   </div>
    <el-table border :data="tableData.list" stripe style="width: 100%" v-loading="loading">
      <el-table-column prop="id" label="ID" width="80">
      </el-table-column>
      <el-table-column prop="name" label="商户名">
      </el-table-column>
      <el-table-column prop="account" label="账号">
      </el-table-column>
      <el-table-column label="操作">
        <template  slot-scope='scope'>
          <div style="white-space: nowrap">
            <el-button type="primary" size="small" @click="seeErCode(scope.row)">二维码管理</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <div class="block" style="text-align: right;padding: 10px 20px;">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="tableData.pageNumber"
        :page-size="tableData.pageSize"
        layout="total, prev, pager, next"
        :total="tableData.totalRow">
      </el-pagination>
    </div>
  </section>
</template>

<script>
  export default {
    data () {
      return {
        tableData: {},
        loading: false,
        page: {
          pageSize: 10,
          pageNumber: 1
        }
      }
    },
    created () {
      this.getErCodeList()
    },
    methods: {
      getErCodeList () {
        this.loading = true
        this.$api.getBusinessList(this.$route.query.id, this.page).then(res => {
          if (res.code === '000000') {
            this.loading = false
            this.$message.success('获取商户列表成功')
            this.tableData = res.data
          }
        })
      },
      seeErCode (row) {
        this.$router.push({
          path: '/upload/list2',
          query: {id: row.id, name: row.name}
        })
      },
      deleteBusiness (id) {
        this.$api.deleteBusiness()
      },
      handleCurrentChange (val) {
        this.page.pageNumber = val
        this.getErCodeList()
      },
      goBack () {
        this.$router.go(-1)
      }
    }
  }
</script>

<style lang="less">
  #uploadBusiness {
    th {
      text-align: center;
    }

    .el-input__inner {
      height: 25px;
      font-size: 12px;
    }
    .el-input {
      width: 160px;
      display: inline-block;
      margin: 0 8px;
      margin: 0;
    }
    .title1 {
      font-size: 14px;
    }
  }
</style>
